<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
	<include file="Public:meta" />
</head>
<body id="main_page">
<include file="Public:position" />
<div class="container">
    <div class="box">
        <form action="{$Action}" method="post" id="frmSave" enctype="multipart/form-data">
            <input type="hidden" name="{$HiddenName}" value="{$HiddenValue}" />
                <div class="box-header"><h4>活动基本信息</h4></div>
                <div class="box-content">
                    <table class="boxtable">
                      <tr>
                        <th nowrap="nowrap">抽奖形式</th>
                        <td>
                            <label><input type="radio" name="LotteryType" value="0"  onclick="SelectType(0)"  <eq name="l.LotteryType" value="0">checked="checked"</eq>  />大转盘</label>
                            &nbsp;&nbsp;&nbsp;&nbsp;
                            <label><input type="radio" name="LotteryType" value="1"  onclick="SelectType(1)"  <eq name="l.LotteryType" value="1">checked="checked"</eq> />刮刮卡</label>
                        </td>
                    </tr>
    
                        <tr>
                            <th>活动名称</th>
                            <td><input type="text" class="textinput w450"  id="LotteryName" name="LotteryName" value="{$l.AppName}" /></td>
                        </tr>
                                                   <tr>
                            <th>触发关键词</th>
                            <td><input type="text" class="textinput" style="230px"  id="AppKeyword" name="AppKeyword" value="{$l.AppKeyword}" />
                            <span class='Caution'>在微信输入此关键词，将返回当前应用的图文消息！</span>
                            </td>
                        </tr>
                                                 <tr>
                        <th>图文消息封面</th>
                        <td><input type="text" id="wxlotterypictureImage" class="textinput w450" name="LotteryStartPicture" value="{$l.LotteryStartPicture}"  />
                        <span class='UploadWrapper'>
                            <input class='btnFileUpload' type='button' value='上传' />
                            <input id='wxlotterypicture' name ='wxlotterypicture' type ='file'  size='70'   class='InputFile'  accept="image/*" />
                        </span>
                        <input id='btnServer' onclick='BrowserServer(1)' name ='btnServer'  type ='button' value='{$Think.lang.SelectPicture}'  class='btnUpload' />
                        </td>
                    </tr>
                        <tr>
                            <th>活动简介</th>
                            <td><input type="text" class="textinput w450" name="LotteryIntroduction" value="{$l.LotteryIntroduction}"  /></td>
                        </tr>
                        <tr>
                            <th>活动说明</th>
                            <td><textarea class="w450" style="height:50px; width:100%" name="LotteryDescription">{$l.LotteryDescription}</textarea></td>
                        </tr>
                       <tr>
                            <th>活动时间</th>
                            <td><script type='text/javascript' src='{$WebPublic}My97DatePicker/WdatePicker.js'></script>
                            <input name='LotteryStartTime' type='text' class='Wdate' id='LotteryStartTime'  class='textinput' style="width:140px"  onClick="WdatePicker({skin:'whyGreen',dateFmt:'yyyy-MM-dd HH:mm:ss'})" readonly='readonly'   value='{$l.LotteryStartTime}' /><span style="padding:0px 5px">到</span><input name='LotteryEndTime' type='text' class='Wdate' id='LotteryEndTime'  class='textinput' style="width:140px"  onClick="WdatePicker({skin:'whyGreen',dateFmt:'yyyy-MM-dd HH:mm:ss'})" readonly='readonly'   value='{$l.LotteryEndTime}' />
                            </td>
                        </tr>
                        <tr>
                            <th>重复抽奖回复</th>
                            <td><input type="text" class="textinput w450" name="LotteryRepeatTip" value="{$l.LotteryRepeatTip}"  /></td>
                        </tr>
                      </table>
                </div>
                
                <div class="box-header"><h4>活动结束内容</h4></div>
                <div class="box-content">
                    <table class="boxtable">
                        <tr>
                            <th>活动结束标题</th>
                            <td><input type="text" class="textinput w450" name="LotteryEndTitle" value="{$l.LotteryEndTitle}" /></td>
                        </tr>
                        <tr>
                            <th>活动结束说明</th>
                            <td>
                            <textarea class="w450" style="height:50px; width:100%" name="LotteryEndDescription">{$l.LotteryEndDescription}</textarea>
                            </td>
                        </tr>
                    </table>
               </div>
               
                <div class="box-header"><h4>活动奖项</h4></div>
                <div class="box-content">
                    <table class="boxtable">
                        <tr>
                            <th>一等奖奖品</th>
                            <td>
                            <input type="text" class="textinput"  style="width:160px" name="LotteryAward1" value="{$l.LotteryAward1}" />&nbsp;
                            奖品数量<input type="text" class="textinput" style="width:40px" name="LotteryAward1Num" value="{$l.LotteryAward1Num}" />
                            &nbsp;
                            中奖概率<input type="text" class="textinput" style="width:40px" name="LotteryAward1Probability" value="{$l.LotteryAward1Probability}" />
                            <span class='Caution'>单位：万分比，取值范围[0-10000]。0：不可能中奖，10000：一定可以中奖</span>
                            </td>
                        </tr>
                        <tr>
                            <th>二等奖奖品</th>
                            <td>
                            <input type="text" class="textinput"  style="width:160px" name="LotteryAward2" value="{$l.LotteryAward2}" />&nbsp;
                            奖品数量<input type="text" class="textinput" style="width:40px" name="LotteryAward2Num" value="{$l.LotteryAward2Num}" />
                            &nbsp;
                            中奖概率<input type="text" class="textinput" style="width:40px" name="LotteryAward2Probability" value="{$l.LotteryAward2Probability}" />
                            <span class='Caution'>单位：万分比，取值范围[0-10000]。0：不可能中奖，10000：一定可以中奖</span>
                            </td>
                        </tr>
                         <tr>
                            <th>三等奖奖品</th>
                            <td>
                            <input type="text" class="textinput"  style="width:160px" name="LotteryAward3" value="{$l.LotteryAward3}" />&nbsp;
                            奖品数量<input type="text" class="textinput" style="width:40px" name="LotteryAward3Num" value="{$l.LotteryAward3Num}" />
                            &nbsp;
                            中奖概率<input type="text" class="textinput" style="width:40px" name="LotteryAward3Probability" value="{$l.LotteryAward3Probability}" />
                            <span class='Caution'>单位：万分比，取值范围[0-10000]。0：不可能中奖，10000：一定可以中奖</span>
                            </td>
                        </tr>
                         <tr>
                            <th>每人最多抽奖总次数</th>
                            <td>
                            <input type="text" class="textinput"  style="width:160px" name="LotteryMax" value="{$l.LotteryMax}" />
                             <span class='Caution'>必须大于0，无上限，推荐设置为1-5次</span>
                            </td>
                        </tr>
                        <tr>
                            <th>每天最多抽奖次数</th>
                            <td>
                            <input type="text" class="textinput"  style="width:160px" name="LotteryDayMax" value="{$l.LotteryDayMax}" />
                             <span class='Caution'>必须大于0，最大不能超过"每人最多抽奖总次数"，推荐设置为1次</span>
                            </td>
                        </tr>
                        <tr>
                            <th>兑奖说明</th>
                            <td>
                            <input type="text" class="textinput"  style="width:450px" name="LotteryTip" value="{$l.LotteryTip}" />
                             <span class='Caution'>中奖后的提示信息！如：请联系我们兑奖，电话：189xxxxxxx8</span>
                            </td>
                        </tr>
                        <tr>
                            <th>商家兑奖密码</th>
                            <td>
                            <input type="text" class="textinput"  style="width:160px" name="LotteryPassword" value="{$l.LotteryPassword}" />
                             <span class='Caution'>用于商家不登录管理后台的情况下兑奖！</span>
                            </td>
                        </tr>
                    </table>
               </div>
               
                <div class="box-header"><h4>其它选项</h4></div>
                <div class="box-content">
                    <table class="boxtable">
                        <tr>
                            <th>操作说明</th>
                            <td><textarea class="w450" style="height:50px; width:100%" name="AppDescription">{$l.AppDescription}</textarea></td>
                        </tr>
                         <tr>
                            <th nowrap="nowrap">是否启用</th>
                            <td>
                                <label><input type="radio" name="IsEnable" value="1" <eq name="l.IsEnable" value="1">checked="checked"</eq>  />启用</label>&nbsp;&nbsp;
                                <label><input type="radio" name="IsEnable" value="0"  <eq name="l.IsEnable" value="0">checked="checked"</eq>/>禁用</label>
                            </td>
                        </tr>
                    </table>
               </div>
    
    
            <div class="box-footer">
                <div class="box-footer-inner">
                    <input  id="btnSubmit" class="marginright" type="submit"  value="保存" />
                    <input  id="btnSubmit"  type="button" value="返回" class="GoBack"  onclick="GoBack()" />
                </div>
            </div>
        </form>
    </div>
</div>
</body>
</html>
<script type='text/javascript'>
	function BrowserServer(){
		var finder = new CKFinder();
		finder.basePath = '{$WebPublic}ckfinder'; 
		finder.selectActionFunction = SetPictureField;
		finder.popup(); 
	}
	function SetPictureField(fileUrl){
		document.getElementById('wxlotterypictureImage').value = fileUrl;
	}
</script>
<script type="text/javascript">
$(document).ready(function(){
	$('#frmSave').ajaxForm({
		success: complete,
		dataType: 'json'
	});
	
	function complete(data){
		CloseLoadBox();
		if (data.status==1){
			SucceedBox(data.info);
		}else if(data.status==0){
			ErrorBox(data.info);
		}else if(data.status==2){
			ErrorBox(data.info); //上传失败
		}else if(data.status==3){
			$('#'+data.data.ImageField).val(data.data.Path);
			SucceedBox(data.info); //上传成功
		}
	};
	
	 $('#frmSave').submit(function(){
		LoadBox();
		return false;  //为了防止普通浏览器进行表单提交和产生页面导航（防止页面刷新？）返回false  
	 });
	 
	 $('#wxlotterypicture').change(function(){
		   if( !$(this).val() ) return;
		   $('#frmSave').attr('action','{$UploadAction}/currentfile/wxlotterypicture');
		   $('#frmSave').submit();
	 });
	 
	 $('#btnSubmit').click(function(){
		$('#frmSave').attr('action','{$Action}');
	 });
	 
	 $("#wxlotterypictureImage").powerFloat({	targetMode: "ajax",	targetAttr: "value", position: "5-7" });
	 $('#LotteryName').focus();
});

function GoBack(){
	window.location.href = "{$Url}lottery";
}
function SelectType(type){
	var p1 = "{$WebPublic}tpl/wx/images/wheel.jpg";
	var p2 = "{$WebPublic}tpl/wx/images/scratch.jpg";
	var pic = $("#wxlotterypictureImage").val();
	if( p1 == pic || p2 == pic || pic==''){
		var t = (type==0) ? p1 : p2;
		$("#wxlotterypictureImage").val( t );
	}
}
</script>